﻿using System;
using System.Xml;
using System.Xml.Serialization;
using System.Collections;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Collections.ObjectModel;
using System.Xml.Schema;
using System.IO;
using System.Text;
using System.Xml.Linq;
using System.Linq;
using System.Configuration;

using XmlVisualizer.Controllers;
using XmlVisualizer.Logging;

namespace XmlVisualizer.Models {

	/// <summary>
	/// Xsd model.
	/// </summary>
    public class XsdModel : IModel {
		//#region M E M B E R S

		//private ArrayList observers;
		//private Application appModel;
		//private XmlSchemaVisual visualSchema;

		//#endregion

		//#region P R O P E R T I E S

		//public XmlSchemaVisual VisualSchema {
		//    get { return visualSchema; }
		//    set { visualSchema = value; }
		//}

		//#endregion

		//#region M E T H O D S

		//public XsdModel(Application applicationModel) {
		//    appModel = applicationModel;
		//    observers = new ArrayList();
		//}

		//#endregion

		//static void ValidationCallback(object sender, ValidationEventArgs args) {
		//    String errorText = "";
		//    if (args.Severity == XmlSeverityType.Warning)
		//        errorText = "WARNING: ";
		//    else if (args.Severity == XmlSeverityType.Error)
		//        errorText = "ERROR: ";

		//    MessageBox.Show(errorText + args.Message, "Validation error", MessageBoxButton.OK, MessageBoxImage.Error);
		//}

		#region IModel Members

		public void OpenFile(string filename) {
			//try {
			//    XmlTextReader reader = new XmlTextReader(filename);
			//    XmlSchema myschema = XmlSchema.Read(reader, ValidationCallback);

			//    XmlSchemaSet schemes = new XmlSchemaSet();
			//    schemes.Add(myschema);
			//    schemes.Compile();

			//    visualSchema = new XmlSchemaVisual(myschema);
			//} catch (XmlSchemaException ex) {
			//    MessageBox.Show(ex.Message, "Exception", MessageBoxButton.OK, MessageBoxImage.Error);
			//} catch (ArgumentNullException ex) {
			//    MessageBox.Show(ex.Message, "Exception", MessageBoxButton.OK, MessageBoxImage.Error);
			//}

			//foreach (IObserver o in observers) {
			//    o.ShowFile();
			//}
		}

		public void SaveFile(string filename) {
			throw new NotImplementedException();
		}

		public String GetXmlText() {
			return "";
		}

		public void Close() {

		}

		public void RemoveNode(XNode node) {

		}
		#endregion
    }
}